package com.TP.www.service.impl;

import com.TP.www.dao.impl.AppraiseDAO;
import com.TP.www.dao.impl.StoreDAO;
import com.TP.www.po.Appraise;
import com.TP.www.po.Order;
import com.TP.www.po.Store;
import com.TP.www.service.AppraisePort;

import static com.TP.www.constant.Constant.*;

/**
 * @author 邱彦祥
 * 用户评论功能实现类
 */
public class CustomerAppraise implements AppraisePort {
    StoreDAO storeDAO = new StoreDAO();
    AppraiseDAO appraiseDAO = new AppraiseDAO();
    /**
     * 对已完成的订单进行评价
     * @param order 订单
     */
    @Override
    public void addAppraise(Order order) {
        String context;
        System.out.println("对这次订单进行评价(无输入默认好评):");
        context = SYS_SC.nextLine();
        if(context.length() == 0){
            context = "默认好评!";
        }
        Store store= storeDAO.executeQuery(SELECT_STORE_ASSET_BY_ORDERS_ID,order.getId()).get(0);
        appraiseDAO.executeUpdate(ADD_APPRAISE,store.getId(),loginUser.getId(),context);
    }

    @Override
    public void removeAppraise(Appraise appraise) {}
}
